package org.example.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.example.pojo.Clazz;
import org.example.pojo.ClazzQueryParam;

import java.util.List;

@Mapper
public interface ClazzMapper {

    /**
     * 查询所有班级信息
     * @return
     */
    @Select("select c.*, e.name as master_name from clazz c left join emp e on c.master_id = e.id")
    List<Clazz> selectAll();


    /**
     * 分页查询
     * @param clazzQueryParam
     * @return
     */
    Page<Clazz> pageQuery(ClazzQueryParam clazzQueryParam);


    /**
     * 根据id删除班级
     * @param id
     */
    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    /**
     * 根据id查询班级
     * @param id
     * @return
     */
    @Select("select c.*, e.name as master_name from clazz c left join emp e on c.master_id = e.id where c.id=#{id}")
    Clazz selectById(Integer id);

    /**
     * 修改班级信息
     * @param clazz
     */
    void update(Clazz clazz);

    /**
     * 添加班级
     * @param clazz
     */
    void insert(Clazz clazz);

    /**
     * 根据id查询班级名称
     * @param clazzId
     * @return
     */
    @Select("select name from clazz where id=#{clazzId}")
    String selectNameById(Integer clazzId);
}
